package {
	import com.bumpslide.tween.FTween;
	import com.bumpslide.ui.Applet;
	import com.bumpslide.ui.Box;
	import com.bumpslide.ui.PixelIcon;
	
	import flash.display.BitmapData;
	import flash.display.DisplayObject;	

	/**
	 * Drawing pixels from text data and an example of tiling a box background 
	 * 
	 * @mxmlc -sp=../../classes -default-background-color 0xeeeeee -default-frame-rate 31
	 * @author David Knape
	 */
	public class PixelIconDemo extends Applet {


		private var iconData_close:Array = [
			"*   *",
			" * * ",
			"  *  ",   
			" * * ",
			"*   *"			
		];
		
		private var iconData_arrow:Array = [
			"  -",
			" - ",
			"---------------",   
			" - ",
			"  -"			
		];
		
		private var pixel_pixels:Array = [
			' ...    .   .   .   ...  .    ...  ', 
			' .  .   .    . .   .     .   .     ', 
			' ...    .     .    ...   .    ..   ',
			' .      .    . .   .     .      .  ',
			' .      .   .   .   ...  ... ...   '];
			
		private var diagonals:Array = [
			'  /',
			' / ',
			'/  '];
		
		private var filledBox:Box;


		override protected function addChildren():void {
			
			var closeIcon:DisplayObject = addChild( new PixelIcon(iconData_close) );			
			closeIcon.x = 100;
			closeIcon.y = 100;
			
			var arrowIcon:DisplayObject = addChild( new PixelIcon(iconData_arrow) );			
			arrowIcon.x = 150;
			arrowIcon.y = 100;
			
			var pixeltext:DisplayObject = addChild( new PixelIcon(pixel_pixels, 0x000088) );			
			pixeltext.x = 100;
			pixeltext.y = 150;
			
			filledBox = addChild( new Box(0, 10, 50, 100, 200, 1 ) ) as Box;
			filledBox.tileBitmap = new BitmapData(3,3, true, 0x000000);
			filledBox.tileBitmap.draw( new PixelIcon( diagonals, 0x880000) );
		}

		override protected function draw():void {
			FTween.ease( filledBox, 'width', width-200, .15 );
			super.draw();
		}
	}
}
